package com.hentie.drawlib;

import com.hentie.mathlib.Vector2;
import com.hentie.mathlib.Vector3;

public class PlaneMesh extends DrawableObject {

    private float halfWidth = 1.0f;
    private float halfHeight = 1.0f;
    private float textureX = 0.0f;
    private float textureY = 0.0f;
    private float textureWidth = 1.0f;
    private float textureHeight = 1.0f;
	
	public PlaneMesh( float newHalfWidth, float newHalfHeight)
	{
		//Create the vertexPoints
	//	vertexPoints = new Vector3[4];
	//	textureCoords = new Vector2[4];
		
	//	vertexPoints[0] = Vector3.Zero();
	//	vertexPoints[1] = Vector3.Zero();
	//	vertexPoints[2] = Vector3.Zero();
	//	vertexPoints[3] = Vector3.Zero();
	//	textureCoords[0] = Vector2.Zero();
	//	textureCoords[1] = Vector2.Zero();
	//	textureCoords[2] = Vector2.Zero();
	//	textureCoords[3] = Vector2.Zero();
		vertexPoints = new float[12];
		textureCoords = new float[4*2];
		indicies = new short[]{0,1,2,0,2,3};
		UpdatePlane(newHalfWidth,newHalfHeight,0.0f,0.0f,1.0f,1.0f);
		
	}
	
	public void SetTextureName(String textureName)
	{
		this.textureName = textureName;
		
	}
	
    //ChangeQuad function
    //This will readd the points
    public void UpdatePlane(float newHalfWidth, float newHalfHeight, float newTexX, float newTexY, float newTexWidth, float newTexHeight)
    {




        //Set the values
        halfWidth = newHalfWidth;
        halfHeight = newHalfHeight;
        textureX = newTexX;
        textureY = newTexY;
        textureWidth = newTexWidth;
        textureHeight = newTexHeight;
/*
        //Now fill the Verticies
        //TopLeft
        vertexPoints[0].Set(-halfWidth, halfHeight, 0);
        textureCoords[0].Set(textureX, textureY);
         //BottomLeft
        vertexPoints[1].Set(-halfWidth, -halfHeight, 0);
        textureCoords[1].Set(textureX , textureY + textureHeight);       
         //BottomRight
        vertexPoints[2] .Set(halfWidth, -halfHeight, 0);
        textureCoords[2] .Set(textureX + textureWidth, textureY + textureHeight);       
        //TopRight
        vertexPoints[3] .Set(halfWidth, halfHeight, 0);
        textureCoords[3] .Set(textureX + textureWidth, textureY);



*/

        //Top Left
        vertexPoints[0] = - halfWidth; 
        vertexPoints[1] = halfHeight; 
        vertexPoints[2]= 0;
        
        textureCoords[0] = textureX; 
        textureCoords[1] = textureY;
        
      //BottomLeft
        vertexPoints[3] = -halfWidth; 
        vertexPoints[4] = -halfHeight; 
        vertexPoints[5]= 0;
        
        textureCoords[2] = textureX; 
        textureCoords[3] = textureY+ textureHeight;
        
        //BottomRight
        vertexPoints[6] =  halfWidth; 
        vertexPoints[7] = -halfHeight; 
        vertexPoints[8]= 0;
        
        textureCoords[4] = textureX+ textureWidth; 
        textureCoords[5] = textureY+ textureHeight;
        
      //TopRight
        vertexPoints[9] =  halfWidth; 
        vertexPoints[10] = halfHeight; 
        vertexPoints[11]= 0;
        
        textureCoords[6] = textureX + textureWidth; 
        textureCoords[7] = textureY;
        

        
        
       // this.UpdateBuffers();


    }
	
}
